<template>
	<view class="content">
		<view class="video-block">
			<view class="title">视频探秘</view>
			<video :id="'video-'+info.id" :src="info.video" class="video"></video>
			<view class="info">企业可联系平台客服进行岗位推荐及探企拍摄</view>
		</view>
		<view class="tab-block">
			<view class="line"></view>
			<view class="tab-info">
				<view class="tab-item">
					<view class="tab" :class="tabActive==1?'active':''" @click="tabActive=1">在招职位</view>
					<view class="tab" :class="tabActive==2?'active':''" @click="tabActive=2">公司介绍</view>
					<view class="tab" :class="tabActive==3?'active':''" @click="tabActive=3">面试评价</view>
				</view>
				<view class="count">共{{info.enterpriseModel.jobPublishList.length}}个</view>
			</view>
		</view>
		<template v-if="info.enterpriseModel.jobPublishList.length>0&&tabActive==1">
			<view @click="navigate('/page_other/job_hunting/job_detail/index?id='+item.id)" class="aaum-block"
				v-for="(item,index) in info.enterpriseModel.jobPublishList" :key="item.id">
				<view class="info-list">
					<view class="info-title">{{item.jobTitle}}</view>
					<view class="fast-job" v-if="item.worry===1">急招</view>
				</view>
				<view class="info-money" v-if="item.minSalary">{{item.minSalary}}-{{item.maxSalary}}元/月</view>
				<view class="info-money" v-else>面议</view>
				<view class="address-item">
					<view class="address-info">
						<view class="iconfont icon-a-dizhi1"></view>
						<view class="address">{{item.jobAddress}}</view>
					</view>
					<view class="distance">距离:{{item.distance}}km</view>
				</view>
			</view>
		</template>
		<view v-else class="empty">暂无数据</view>
	</view>
</template>

<script>
	import {
		getExploringVideosByIdApi
	} from '@/api/job_hunting.js'
	export default {
		data() {
			return {
				tabActive: 1,
				info: {
					video: '',
					enterpriseModel: {
						jobPublishList: []
					}
				},
			}
		},
		watch: {
			tabActive: {
				handler() {
					if (this.tabActive == 2) {
						this.navigate('/page_other/company/company?id=' + this.info.enterpriseModel.id)
					}
				},
			},
		},
		methods: {
			getInfo() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getExploringVideosByIdApi({
					id: this.id
				}).then((res) => {
					this.info = res ?? [];
				}).catch((res) => {
					this.showToast('公司信息不存在', function() {
						this.back()
					})
				})
			},
		},
		onLoad(e) {
			this.id = e.id
			uni.setNavigationBarTitle({
				title: e.title
			});
			this.getInfo()
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 30rpx;

		.video-block {
			padding: 30rpx;
			background-color: #FFFFFF;
			border-radius: 30rpx;

			.title {
				font-size: 32rpx;
				font-weight: bold;
				margin-bottom: 20rpx;
			}

			.video {
				width: 100%;
				height: 300rpx;
				border-radius: 20rpx;
			}

			.info {
				margin-top: 20rpx;
				font-size: 28rpx;
				color: #767676;
			}
		}

		.tab-block {
			margin: 30rpx 0;
			display: flex;
			align-items: center;

			.line {
				height: 40rpx;
				width: 20rpx;
				background-color: #0256FF;
				border-radius: 30rpx;
				margin-right: 10rpx;
			}

			.tab-info {
				width: calc(100% - 30rpx);
				display: flex;
				align-items: center;
				justify-content: space-between;

				.tab-item {
					display: flex;
					align-items: center;

					.tab {
						margin-right: 30rpx;
						font-size: 32rpx;
						font-weight: bold;
					}

					.tab.active {
						color: #0256FF;
					}
				}

				.count {
					font-size: 30rpx;
					color: #767676;
				}
			}
		}

		.aaum-block {
			margin-top: 30rpx;
			padding: 30rpx;
			font-size: 28rpx;
			display: flex;
			flex-direction: column;
			background: #FFFFFF;

			.info-item {
				width: 100%;
				padding: 10rpx 0;
				overflow: hidden;
				text-overflow: ellipsis;
				// white-space: nowrap;
			}

			.info-list {
				display: flex;
				flex-direction: row;
				margin-bottom: 20rpx;

				.info-title {
					overflow: hidden;
					text-overflow: ellipsis;
					font-size: 32rpx;
					font-weight: bold;
					flex-grow: 1;
				}

				.fast-job {
					width: 60rpx;
					height: 38rpx;
					background: #E4EFFF;
					font-size: 24rpx;
					text-align: center;
					color: #0256FF;
					margin-left: 20rpx;
					border-radius: 6rpx;
				}
			}

			.info-money {
				color: #0256FF;
				font-size: 30rpx;
			}

			.address-item {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				color: #767676;
				margin-top: 20rpx;

				.address-info {
					width: calc(100% - 200rpx);
					display: flex;
					align-items: center;

					.iconfont {
						margin-right: 6rpx;
					}

					.address {
						width: calc(100% - 26rpx);
						font-size: 28rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
				}

				.distance {
					width: 200rpx;
					font-size: 28rpx;
					text-align: end;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
			}
		}
	}
</style>